# Build recipe for mutagen
#
# Copyright (c) 2018 Markus Tornow, <tornow@riseup.net>.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

program=mutagen
version=1.41.1
release=1
srcdir=${program}-release-${version}

# Set 'outdir' for a nice and well-organized output directory
outdir="${outdir}/${arch}/modules/python"

tarname=${program}-release-${version}.tar.gz

# Remote source(s)
fetch=http://github.com/quodlibet/mutagen/archive/release-1.41.1/"$tarname"


description="
Mutagen is a Python module to handle audio metadata. 

It supports ASF, FLAC, MP4, Monkey's Audio, MP3, Musepack, Ogg Opus,
Ogg FLAC, Ogg Speex, Ogg Theora, Ogg Vorbis, True Audio, WavPack,
OptimFROG, and AIFF audio files. All versions of ID3v2 are supported,
and all standard ID3v2.4 frames are parsed.  It can read Xing headers
to accurately calculate the bitrate and length of MP3s. ID3 and APEv2
tags can be edited regardless of audio format. It can also manipulate
Ogg streams on an individual packet/page level.

Mutagen works with Python 2.7, 3.4+ (CPython and PyPy) on Linux,
Windows and macOS, and has no dependencies outside the Python standard
library. Mutagen is licensed under the GPL version 2 or later.
"

homepage=http://github.com/quodlibet/mutagen
license="GPLv2"

docs="COPYING MANIFEST.in README.rst NEWS"
docsdir="${docdir}/${program}-${version}"

build()
{
    set -e

    unpack "${tardir}/$tarname"

    cd "$srcdir"

    # Set sane permissions
    chmod -R u+w,go-w,a+rX-s .

    # Install for both, Python versions 2 and 3

    for i in 2 3
    do
        python${i} setup.py build
        python${i} setup.py install --prefix=/usr --root="$destdir" --optimize=1
    done
    unset i

    # Copy documentation
    mkdir -p "${destdir}${docsdir}"
    cp -p $docs "${destdir}${docsdir}"
}

